import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)//全局注册路由
//定义了一个数组常量
const routes = [
  {
    // 首页
    path: '/',
    name: 'home',
    component: HomeView,
    children:[
      {
        path: '/manager',
        name: 'manager',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '@/views/manager')
      },
      {
        path: '/role',
        name: 'role',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '@/views/role')
      },
      {
        path: '/perm',
        name: 'perm',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '@/views/perm')
      }
    ]
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path:'/menu',
    name:'menu',
    component: () => import(/* webpackChunkName: "about" */ '@/views/MenuView.vue'),
    //因为我们的页面是在menu这个路由下的二级路由，所以必须配置在这边。
    children:[//是一级路由menu下的二级路由
      {
        path:'/login',
        name:'login',
        component: () => import(/* webpackChunkName: "about" */ '@/views/login/login.vue'),
      },
      {
        path:'/register',
        name:'register',
        component: () => import(/* webpackChunkName: "about" */ '@/views/login/register.vue'),
      }
    ]
  }
]

const router = new VueRouter({
  routes
})
//ES6中 导入导出功能，类似java中的return new VueRouter({routes});
export default router